Module (chicken fixnum)
Because CHICKEN supports a full numeric tower, operations can sometimes incur a substantial overhead to simply detect the type of numbers you're passing in. When you know you're definitely dealing only with fixnums, you can choose to use fixnum-specific operations to avoid this overhead.
This is purely a performance hack. You might want to consider adding type annotations instead, this often gives the same performance boost without having to rewrite all numeric operators in your code.
Arithmetic fixnum operations
[procedure] (fx+ N1 N2)[procedure] (fx- N1 N2)
[procedure] (fx* N1 N2)
[procedure] (fx/ N1 N2)
[procedure] (fxmod N1 N2)
[procedure] (fxrem N1 N2)
[procedure] (fxneg N)
[procedure] (fxmin N1 N2)
[procedure] (fxmax N1 N2)
[procedure] (fxand N1 N2)
[procedure] (fxior N1 N2)
[procedure] (fxxor N1 N2)
[procedure] (fxnot N)
[procedure] (fxshl N1 N2)
[procedure] (fxshr N1 N2)
[procedure] (fxgcd N1 N2)
fx+ and friends are arithmetic fixnum operations. These procedures do not check their arguments, so non-fixnum parameters will result in incorrect results. fxneg negates its argument.
On division by zero, fx/, fxmod and fxrem signal a condition of kind (exn arithmetic).
fxshl and fxshr perform arithmetic shift left and right, respectively.
Overflow-aware fixnum operations
[procedure] (fx+? N1 N2)[procedure] (fx-? N1 N2)
[procedure] (fx*? N1 N2)
[procedure] (fx/? N1 N2)
These procedures behave similarly to their standard counterparts with the exception that #f is returned if an argument is not a fixnum or the result of the operation overflows.
Chaining of such procedures is well-defined and causes the overflow error to be propagated.
Fixnum comparison and predicates
[procedure] (fxodd? N)[procedure] (fxeven? N)
[procedure] (fx= N1 N2)
[procedure] (fx> N1 N2)
[procedure] (fx< N1 N2)
[procedure] (fx>= N1 N2)
[procedure] (fx<= N1 N2)
Comparison of fixnums and predicates on them.
Fixnum limits
[constant] most-positive-fixnum[constant] most-negative-fixnum
[constant] fixnum-bits
[constant] fixnum-precision
Platform-specific fixnum limits.
Previous: Module (chicken file posix)
Next: Module (chicken flonum)